<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags"%>

<%@include file="/common/head.jsp" %>

<c:set var="module" value="user"/>

<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
		<form action="${ctx }/admin/user/factorySave?id=${n.id }&user.id=${n.user.id }" id="detail-form" class="form-horizontal" method="post">
			<div class="form-group">
                 <label class="col-sm-2 control-label">用户名</label>
                 <div class="col-sm-10">
                 	<input type="text" class="form-control" name="user.username" ${empty n.id ? '' : 'readonly' } value="${n.user.username }">
                 </div>
             </div>	
             <c:if test="${empty n.id}">
             <div class="form-group">
                 <label class="col-sm-2 control-label">密码</label>
                 <div class="col-sm-10">
                 	<input type="text" class="form-control" name="user.password" value="${n.user.password }">
                 </div>
             </div>	
             </c:if>
              <div class="form-group">
                 <label class="col-sm-2 control-label">公司名称</label>
                 <div class="col-sm-10">
                 	<input type="text" class="form-control" name="companyName" value="${n.companyName }">
                 </div>
             </div>	
             <div class="form-group">
                 <label class="col-sm-2 control-label">供应商对应码</label>
                 <div class="col-sm-10">
                 	<input type="text" class="form-control" name="user.seq" value="${n.user.seq }">
                 </div>
             </div>	
			<div class="form-group">
                 <label class="col-sm-2 control-label">省</label>
                 <div class="col-sm-10">
					<select name="user.province.id" class="form-control" id="provinceId">
						<c:forEach items="${provinces }" var="p">
						<option value="${p.id }" ${n.user.province.id eq p.id ? 'selected' : '' }>${p.name }</option>
						</c:forEach>
					</select>						                 	
                 </div>
                 
             </div>	
			<div class="form-group">
                 <label class="col-sm-2 control-label">城市</label>
                 <div class="col-sm-10">
                 	<select name="user.city.id" class="form-control" id="cityId">
                 		<c:if test="${not empty(n.user.city.id) }">
                 		<option value="${n.user.city.id }">${n.user.city.name }</option>
                 		</c:if>
					</select>	
                 </div>
             </div>	
			<div class="form-group">
                 <label class="col-sm-2 control-label">地区</label>
                 <div class="col-sm-10">
                 	<select name="user.district.id" class="form-control" id="districtId">
	                 	<c:if test="${not empty(n.user.district.id) }">
	                 		<option value="${n.user.district.id }">${n.user.district.name }</option>
                 		</c:if>
					</select>
                 </div>
             </div>	
			<div class="form-group">
                 <label class="col-sm-2 control-label">工厂规模</label>
                 <div class="col-sm-10">
                 	<select class="form-control" name="companySize">
		                <option value="">请选择</option>
		                <option value="100以下" ${n.companySize eq '100以下' ? 'selected' : '' }>100人以下</option>
		                <option value="100以上" ${n.companySize eq '100以上' ? 'selected' : '' }>100人以上</option>
            		</select>
                 </div>
             </div>	
			<div class="form-group">
                 <label class="col-sm-2 control-label">联系人</label>
                 <div class="col-sm-10">
                 	<input type="text" class="form-control" name="user.contactName" value="${n.user.contactName }">
                 </div>
             </div>	
             <div class="form-group">
                 <label class="col-sm-2 control-label">联系人电话</label>
                 <div class="col-sm-10">
                 	<input type="text" class="form-control" name="user.mobile" value="${n.user.mobile }">
                 </div>
             </div>	
             <div class="form-group">
                 <label class="col-sm-2 control-label">qq</label>
                 <div class="col-sm-10">
                 	<input type="text" class="form-control" name="user.QQ" value="${n.user.QQ}">
                 </div>
             </div>	
			<div class="form-group">
                 <label class="col-sm-2 control-label">视频链接</label>
                 <div class="col-sm-10">
                 	<input type="text" class="form-control" name="videourl" value="${n.videourl }">
                 </div>
             </div>	
             <div class="form-group">
                 <label class="col-sm-2 control-label">直播链接</label>
                 <div class="col-sm-10">
                 	<input type="text" class="form-control" name="liveurl" value="${n.liveurl }">
                 </div>
             </div>	
		</form>
</div>

<%@include file="/common/foot.jsp" %>

<script>
$('#provinceId').change(function() {
	var provinceId = $(this).val();
	$('#cityId').html('');
	$('#districtId').html('');
	if (provinceId != '') {
		$.ajax({
			url: "${ctx}/admin/province/findArea?provinceId=" + provinceId,
			dataType: "json",
			success: function(array) {
				$('#cityId').append('<option value="">城市</option>');
				for (var i = 0; i < array.length; i++) {
					var obj = array[i];
					var option = '<option value="' + obj.id + '">' + obj.name + '</option>';
					$('#cityId').append(option);	
				}
			}
		});
	}
	
});

$('#cityId').change(function() {
	var cityId = $(this).val();
	$('#districtId').html('');
	if (cityId != '') {
		$.ajax({
			url: "${ctx}/admin/province/findArea?cityId=" + cityId,
			dataType: "json",
			success: function(array) {
				$('#districtId').append('<option value="">地区</option>');
				for (var i = 0; i < array.length; i++) {
					var obj = array[i];
					var option = '<option value="' + obj.id + '">' + obj.name + '</option>';
					$('#districtId').append(option);	
				}
			}
		});
	}
	load_filter_user();
});

$('#districtId').change(function() {
	load_filter_user();
});

$(document).ready(function() {
	init_images('image1');
});
</script>
</body>
</html>
